import express from 'express';
const app = express();
const port = 8888;

// 允许跨域请求 (CORS)
import cors from 'cors';
app.use(cors());

// 解析 JSON 请求体
app.use(express.json());

// 定义一个简单的接口
app.get('/api/test', (req, res) => {
  res.json({ message: 'Hello, this is a response from the API!' });
});

// 启动服务器
app.listen(port, () => {
  console.log(`Server is running at http://localhost:${port}`);
});
